# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=py3-pyside2
pkgver=5.15.2
pkgrel=3
pkgdesc="Enables the use of Qt5 APIs in Python applications"
url="https://doc.qt.io/qtforpython-5/"
# armhf blocked by shiboken2
# riscv64 blocked by qt5-qtwebengine
arch="all !armhf !riscv64"
license="LGPL-3.0-only AND GPL-2.0-only"
depends="py3-shiboken2"
makedepends="
	cmake
	libshiboken2-dev
	py3-shiboken2
	qt5-qt3d-dev
	qt5-qtbase-dev
	qt5-qtcharts-dev
	qt5-qtdatavis3d-dev
	qt5-qtdeclarative-dev
	qt5-qtlocation-dev
	qt5-qtmultimedia-dev
	qt5-qtquickcontrols2-dev
	qt5-qtremoteobjects-dev
	qt5-qtscript-dev
	qt5-qtscxml-dev
	qt5-qtsensors-dev
	qt5-qtserialport-dev
	qt5-qtspeech-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtwebchannel-dev
	qt5-qtwebsockets-dev
	qt5-qtx11extras-dev
	qt5-qtxmlpatterns-dev
	shiboken2
	py3-setuptools
	"
if [ "$CARCH" != "ppc64le" ] && [ "$CARCH" != "s390x" ]; then
	makedepends="$makedepends qt5-qtwebengine-dev"
fi
subpackages="$pkgname-dev"
# download.qt.io is down at the moment, see https://www.qt.io/blog/problem-with-open-source-downloads
#source="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-$pkgver-src/pyside-setup-opensource-src-$pkgver.tar.xz"
source="
	http://mirrors.ukfast.co.uk/sites/qt.io/official_releases/QtForPython/pyside2/PySide2-$pkgver-src/pyside-setup-opensource-src-$pkgver.tar.xz
	python-3.10.patch"
builddir="$srcdir/pyside-setup-opensource-src-$pkgver"
options="!check" # Tests fail

build() {
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DPYTHON_EXECUTABLE=/usr/bin/python3 \
		-DBUILD_TESTS=OFF \
		sources/pyside2
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Install egg info
	export PATH="/usr/lib/qt5/bin:$PATH"
	python3 setup.py egg_info --build-type=pyside2
	pythonpath="$(python3 -c "from sysconfig import get_path; print(get_path('platlib'))")"
	cp -r PySide2.egg-info "$pkgdir/$pythonpath"
}

sha512sums="
5043c1c9db4ba0133baaabb4d4943182e9741b1007bedd992394758707a37bba0688dc6413ea46620e7c2fb09daa3c74e6a7bb2c302b9d08e5f3bb7575d02b62  pyside-setup-opensource-src-5.15.2.tar.xz
a7e37bc1148b4df37b37fd5747f2e6596a5bf554369a63187bff193c66e2caba1719821ffb69ce5d647efd7aa73c8047607970239b07eea6a4814e924b4c3d4c  python-3.10.patch
"
